* Generate variables for effects of mass shootings in nearby states

set more off

// regional shooting interactions  {{{
foreach v of varlist cendiv cenreg {
    cap confirm numeric variable `v'_shoot
    if _rc {
        egen byte `v'_shoot = max(`shoot'), by(`v' year)
        la var `v'_shoot "Shooting in `v'"
    }
    cap confirm numeric variable `v'_fatal
    if _rc {
        egen int `v'_fatal = total(`fatal'), by(`v' year)
        la var `v'_fatal "Fatalities in `v'"
    }

}  // }}}


// political interactions  {{{
foreach party in "dem" "rep" "spl" {
    loc lblp: var label `party'leg

    foreach v of varlist cendiv cenreg {
        capture drop `v'_fatalX`party'leg
        gen `v'_fatalX`party'leg = L.`v'_fatal * `party'leg
        la var `v'_fatalX`party'leg "`lblp' X `v' fatalities"

        capture drop `v'_shootX`party'leg
        gen `v'_shootX`party'leg = L.`v'_shoot * `party'leg
        la var `v'_shootX`party'leg "`lblp' X `v' shooting"
    }

    capture drop adjfatalX`party'leg
    gen adjfatalX`party'leg = L.`adjfatal' * `party'leg
    la var adjfatalX`party'leg "`lblp' X `v' fatalities"

    capture drop adjshootX`party'leg
    gen adjshootX`party'leg = L.`adjshoot' * `party'leg
    la var adjshootX`party'leg "`lblp' X `v' shooting"
}  // }}}

exit
// vim: foldmethod=marker
